<template>
  <el-dialog
    :title="title"
    v-if="dialogSquare"
    :visible.sync="dialogSquare"
    @close="cancelAdd"
  >
    <el-form :model="detailForm" ref="detailForm">
      <el-row>
        <el-col :span="12">
          <el-form-item label="标题：" :label-width="formLabelWidth" prop="title">
            <span>{{form.title}}</span>
          </el-form-item>
          <el-form-item label="状态：" :label-width="formLabelWidth" prop="status">
            <span v-if="form.status == 0">删除</span>
            <span v-if="form.status == 1">审核通过</span>
            <span v-if="form.status == 2">审核驳回</span>
            <span v-if="form.status == 3">未审核</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="标题图片：" :label-width="formLabelWidth">
            <imgs-upload v-model="form.titleImg" :limit="1" :prompt="false" disabled/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="是否原创：" :label-width="formLabelWidth" prop="isOriginal">
            <span>{{form.isOriginal == 1 ? '原创' : '转载'}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="开启评论：" :label-width="formLabelWidth" prop="openComment">
            <span>{{form.openComment == 1 ? '是' : '否'}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="用户：" :label-width="formLabelWidth"  prop="author">
            <span>{{form.author}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="文章出处：" :label-width="formLabelWidth" v-if="form.isOriginal==0" >
            <span>{{form.articlesPart}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22">
          <el-form-item label="内容：" :label-width="formLabelWidth" prop="content">
            <tiny-mce
              ref="content"
              :key="form.uid"
              v-model="form.content"
              tinymceUploadType="prod"
            ></tiny-mce>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item style="float: right; margin-right: 20px;">
            <el-button  @click="cancelAdd">取 消</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>

  <el-dialog
    :title="title"
    v-else-if="dialogCircle"
    :visible.sync="dialogCircle"
    @close="cancelAdd"
  >
    <el-form :model="friendForm" ref="friendForm">
      <el-row>
        <el-col>
          <el-form-item label="内容：" :label-width="formLabelWidth" prop="content" v-if="reportType < 2">
            <span>{{form.content}}</span>
          </el-form-item>
          <el-form-item label="图片：" :label-width="formLabelWidth" v-if="reportType != 1">
            <imgs-upload v-model="form.titleImg" :limit="1" :prompt="false" @input="imgsChange" disabled/>
          </el-form-item>
          <el-form-item label="作者：" :label-width="formLabelWidth" v-if="reportType == 0 && form.isOriginal==0" prop="author">
            <span>{{form.author}}</span>
          </el-form-item>
          <el-form-item label="原文状态：" :label-width="formLabelWidth" v-if="reportType == 0" prop="status">
            <span v-if="form.status == 0">删除</span>
            <span v-if="form.status == 1">审核通过</span>
            <span v-if="form.status == 2">审核驳回</span>
            <span v-if="form.status == 3">未审核</span>
          </el-form-item>
          <el-form-item label="评论状态：" :label-width="formLabelWidth" v-else-if="reportType == 1" prop="status">
            <span v-if="form.status == 0">删除</span>
            <span v-if="form.status == 1">正常</span>
            <span v-if="form.status == 2">违规删除</span>
          </el-form-item>
          <el-form-item label="用户状态：" :label-width="formLabelWidth" v-else-if="reportType == 2" prop="status">
            <span v-if="form.status == 0">禁用</span>
            <span v-if="form.status == 1">正常</span>
          </el-form-item>
          <el-form-item label="群状态：" :label-width="formLabelWidth" v-else-if="reportType == 3" prop="status">
            <span v-if="form.status == 0">正常</span>
            <span v-if="form.status == 1">已解散</span>
          </el-form-item>
          <el-form-item style="display: flex;justify-content: flex-end; margin-right: 20px;margin-bottom: 20px;">
            <el-button  @click="cancelAdd">取 消</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
  import ImgsUpload from '@/components/imgs-upload/index'
  import TinyMce from '@/components/tiny-mce/index'

  export default {
    components: {
      ImgsUpload,
      TinyMce
    },
    data () {
      return {
        resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
        formLabelWidth: '120px',
        dialogSquare: false, // 广场详情
        dialogCircle: false, // 朋友圈详情
        detailForm: {},
        friendForm: {},
        form: {},
        title: '详情',
        reportType: 0
      }
    },
    created () {},
    methods: {
      init (row) {
        this.reportType = row.reportType
        if (row.reportSou == 2) {
          this.title = '聊天记录'
          this.dialogCircle = true
          this.form.status = row.chatStatus
          this.form.titleImg = row.reportPics
        } else {
          if (row.reportType == 0) {
            this.title = '原文详情'
            this.$http({
              url: this.$http.adornUrl('/admin/blog/getById/' + row.reportObjId),
              method: 'get'
            }).then(({data}) => {
              this.form = data
              if (row.reportShopId == null) {
                this.dialogCircle = true
              } else {
                this.$nextTick(() => {
                  this.$refs.content.setData(this.form.content)
                })
                this.dialogSquare = true
              }
            })
          } else {
            this.title = '评论详情'
            this.dialogCircle = true
            this.$http({
              url: this.$http.adornUrl('/admin/blogComment/getComment/by/' + row.reportObjId),
              method: 'get'
            }).then(({data}) => {
              this.form = data
            })
          }
        }
      },
      imgsChange () {
        if (this.form.photoList) {
          this.$refs.form.validateField('photoList')
        }
      },
      cancelAdd: function () {
        this.dialogSquare = false
        this.dialogCircle = false
        this.form = {}
      }
    }
  }
</script>

<style lang="scss">

</style>
